trigger UpdateHCPStatus on Hospital__c (after update) {
list<hcp__c> hcpl=new list<hcp__c>();
list<id> hosid=new list<id>();
boolean b=false;
for(hospital__c h:trigger.new){
    if(Trigger.oldMap.get(h.Id).Active__c == true && h.Active__c == false){
        hosid.add(h.id);
        b=true;
    }
}
if(b){
    hcpl=[select name,id from hcp__c where hospital__c in:hosid];
    for(hcp__c h:hcpl){
        h.active__c=false;
    }
    update hcpl;
}
}